package com.twu.biblioteca;

/**
 * Created with IntelliJ IDEA.
 * User: Anuja Kelkar
 * Date: 7/4/13
 * Time: 11:59 AM
 * To change this template use File | Settings | File Templates.
 */
public class User {
    private String uname;
    private String name;
    private String pwd;
    private String emailID;
    private String phno;

   public User(String uname,String name, String pwd, String emailID, String phno)
    {
        this.uname=uname;
        this.name=name;
        this.pwd=pwd;
        this.emailID=emailID;
        this.phno=phno;
    }

    public User(int n)
    {
      this.uname="";
      this.phno="";
      this.emailID="";
      this.name="";
      this.pwd="";
    }

    //function to check if uname and pwd correspond to a registered user
    int isRegisteredUser(String uname, String pwd)
    {
        if(this.uname.equals(uname))
        {
            if(this.pwd.equals(pwd))
                return(1);
            return(0);
        }
        return(0);
    }

    //function to return index of a user object u in user array
    int returnUserIndex(User u)
    {
        String [] username={"111-1111","111-1112","111-1113","111-1114","111-1115"};
        for(int i=0;i<5;i++)
        {
            if(u.uname.equals(username[i]))
                return(i);
        }
        return(-1);
    }

    //function to retrieve username
    String getUsername(int i)
    {
        String [] username={"111-1111","111-1112","111-1113","111-1114","111-1115"};
        return(username[i]);
    }

    //function to retrieve name
    String getName(int i)
    {
        String [] name= {"Anuja","Dilip","Parth","Aditi","Suman"};
        return(name[i]);
    }

    //function to retrieve pwd
    String getPwd(int i)
    {
        String [] pwd={"abc","def","ghi","jkl","mno"};
        return(pwd[i]);
    }

    //function to retrieve phone number
    String getPhno(int i)
    {
        String [] phno ={"9807767676","9434122321","9023104511","8140067811","8066732109"};
        return(phno[i]);
    }

    //function to retrieve email ID
    String getEmailID(int i)
    {
        String [] emailID={"u1@gmail.com","u2@gmail.com","u3@gmail.com","u4@gmail.com","u5@gmail.com"};
        return(emailID[i]);
    }
}
